package cn.edu.hitwh.kanlema.controller;


import cn.edu.hitwh.kanlema.dto.Result;
import cn.edu.hitwh.kanlema.service.IFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author vvcoder
 * @since 2025-8-18
 */
@RestController
@RequestMapping("/follow")
public class FollowController {
    @Autowired
    private IFollowService followService;

    @PutMapping("/{id}/{follow}")
    public Result follow(@PathVariable("id") Long id, @PathVariable("follow") Boolean follow) {
        return followService.follow(id, follow) ? Result.ok() : Result.fail("操作失败");
    }

    @GetMapping("/or/not/{id}")
    public Result isFollow(@PathVariable("id") Long id) {
        return Result.ok(followService.isFollow(id));
    }

    @GetMapping("/common/{id}")
    public Result commonFollow(@PathVariable("id") Long id) {
        return Result.ok(followService.commonFollow(id));
    }
}
